#!/usr/bin/perl -w

use Test::More tests => 45;
use Test::Exception;
use Cwd qw/abs_path/;
use blib;
use strict;

use Data::Dumper;

my $debug = 1;

BEGIN {
use_ok( 'WebPAC::Input' );
}

ok(my $abs_path = abs_path($0), "abs_path");
$abs_path =~ s#/[^/]*$#/#;

my $module = 'WebPAC::Input::Excel';
diag "testing with $module";

ok(my $input = new WebPAC::Input(
	module => $module,
	no_log => 0,
	no_progress_bar => 1,
	debug => $debug,
), "new");

ok(my $db = $input->open(
	path => "$abs_path/data/excel_95.xls"
), "open");
ok(my $size = $input->size, "size");

foreach my $mfn ( 1 ... $size ) {
	my $rec = $input->fetch;
	if ($mfn <= 10 || $mfn == 20) {
		ok($rec, "fetch $mfn");
	} else {
		ok(! $rec, "empty $mfn");
	}

	cmp_ok($input->pos, '==', $mfn, "pos $mfn");

	diag "rec: ", Dumper($rec), "\n";
}

